<template>
  <div class="login_bg">
    <div class="login_bg3">
      <div class="login_bg2">
        <div class="login_black_hg">
          <!--                    <div class="head_log">-->
          <!--                        后台管理系统-->
          <!--                        <p>ELECTRICITY SYSTEM</p>-->
          <!--                    </div>-->
          <!--                    <div class="unline" style="margin-bottom:30px;"></div>-->
          <!--                    <div class="form-group">-->
          <!--                        <a-input v-model="username" @keyup.enter="login"></a-input>-->
          <!--                    </div>-->
          <!--                    <div class="form-group">-->
          <!--                        <a-input v-model="password" type="password" @keyup.enter="login"></a-input>-->
          <!--                    </div>-->
          <!--                    <div class="form-group" style="font-size:12px;">-->
          <!--                        <a-checkbox name="isCheck" v-model="isCheck" label="1">-->
          <!--                            <font style="font-size:12px;">我已同意</font>-->
          <!--                        </a-checkbox>-->
          <!--                        <a class="must_rad" href="#">《系统用户使用协议》</a>（必读）-->
          <!--                        <a class="must_rad Dblock">注册账户</a>-->
          <!--                    </div>-->
          <!--                    <div class="form-group">-->
          <!--                        <a-button type="primary" block  @click="login">登 陆</a-button>-->
          <!--                    </div>-->
          <!--                  ======================左侧title和图片=========================  -->
          <div class="left">
            <div class="title">创翔综合智慧平台登录</div>
            <div class="icon"></div>
          </div>
          <div class="right">
            <div class="title">Hello,欢迎登录</div>
            <div class="subtitle">WELCOME TO THE SYSTEM</div>
            <div class="username">
              <a-input
                type="text"
                v-model="username"
                placeholder="请输入后台账号"
              />
            </div>
            <div class="username">
              <a-input
                type="password"
                v-model="password"
                @keyup.enter="login"
                placeholder="请输入登录密码"
              />
            </div>
            <div class="zhuce">
              <!-- <span @click="goRegister">还没注册，立即注册</span> -->
              <span></span>
              <span>忘记密码？</span>
            </div>
            <div class="login" @click="login">登录</div>
            <!-- 其他平台登录 -->
            <div class="other_login">
              <div class="line"></div>
              <div class="text">其他平台登录</div>
              <div class="line"></div>
            </div>
            <div class="platform">
              <div @click="$router.push('/Seller/login')">
                <img src="../../asset/login/shangjia@3x.png" alt="" />
                <span>商家端登录</span>
              </div>
              <div @click="$router.push('/Estate/login')">
                <img src=".././../asset/login/wuye@2x.png" alt="" />
                <span>物业登录</span>
              </div>
            </div>
          </div>
        </div>
        <div class="clear"></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "login",
  data() {
    return {
      username: "",
      password: "",
      isCheck: true,
    };
  },
  methods: {
    //跳转注册页面
    goRegister() {
      this.$router.push({ name: "admin_register" });
    },
    // 登录
    login: function () {
      // 重新赋值vm使 axios可用vue实例
      var vm = this;
      if (!this.isCheck) {
        this.$message.error("请先认真阅读本站协议！");
        return;
      }

      if (this.username == "" || this.password == "") {
        this.$message.error("用户名和密码不能为空！");
        return;
      }

      this.$post(this.$api.adminLogin, {
        username: this.username,
        password: this.password,
      }).then(function (res) {
        if (res.code == 200) {
          console.log(res.data);
          // 存储用户的token
          localStorage.setItem("admin_token", res.data.token);
          vm.$setCacheItem("admin_info", res.data.user_info);
          vm.$message.success("登录成功！");
          vm.$router.push({ name: "admin_default" });
        } else {
          vm.$message.error(res.msg);
        }
      });
    },
  },
  created: function () {
    var _this = this;
    // 判断token是否失效
    this.$get(this.$api.adminCheckLogin).then(function (res) {
      // console.log(res);
      if (res.code == 200) {
        _this.$router.push({ name: "admin_default" });
      }
    });
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.login_bg {
  background-position: center;
  background-size: 100%;
  height: 100%;
  background-color: #f1f1f1;
  background-image: url("../../asset/login/ping_login_bg@2x.png");
  /*background-image: linear-gradient(to right, #5d80fe , #56c9ff);*/
}
.head_log {
  text-align: center;
  line-height: 20px;
  font-size: 30px;
}
.head_log p {
  color: #666;
  line-height: 40px;
  font-size: 12px;
  margin-bottom: 10px;
}
.login_bg2 {
  position: relative;
  top: 50%;
  width: 100%;
  margin: 0 auto;
  /* margin-top: -250px; */
  display: block;
}
.login_bg3 {
  height: 100%;
  width: 100%;
  /*background: url('../../asset/login/bg.png');*/
  /*background-position: top right;*/
  /*background-position: top right;*/
  /*background-repeat: no-repeat;*/
}
.login_bg2:after {
  display: block;
  content: "";
  clear: both;
}
.login_black_hg {
  /*background: #fff;*/
  /*width: 360px;*/
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  width: 1500px;
  // height: 701px;
  height: 886px;
  border-radius: 6px;
  padding: 0px 40px 20px 40px;
  box-sizing: border-box;
  -moz-box-sizing: border-box; /* Firefox */
  -webkit-box-sizing: border-box; /* Safari */
  padding-top: 40px;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
  margin: auto;
  background: url("../../asset/login/bg_two@3x.png") no-repeat;
  background-size: 100% 100%;
  .left {
    height: 100%;
    .title {
      font-size: 40px;
      font-family: Source Han Sans CN;
      font-weight: bold;
      // color: #32c19c;
      color: #4c9bdd;
    }
    .icon {
      width: 672px;
      margin-top: 40px;
      // height: 400px;
      height: 738px;
      background: url("../../asset/login/ping_tutu@3x.png") no-repeat;
      background-size: 100% 100%;
    }
  }
  .right {
    width: 444px;
    height: 100%;
    margin-right: 80px;
    .title {
      text-align: center;
      font-size: 36px;
      font-family: Source Han Sans CN;
      font-weight: bold;
      color: #4c9bdd;
      line-height: 58px;
      text-shadow: 2px 8px 9px rgba(138, 138, 138, 0.12);
      background: linear-gradient(0deg, #62a8e2 0%, #4c9bdd 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }
    .subtitle {
      margin-top: 20px;
      margin-bottom: 50px;
      font-size: 21px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #b4b4b4;
      line-height: 24px;
      text-align: center;
    }
    .username {
      width: 100%;
      height: 64px;
      border-radius: 32px;
      background-color: #f6f7fb;
      margin-bottom: 36px;
      & > input {
        border: none;
        background-color: transparent;
        height: 100%;
        width: 100%;
        border-radius: 32px;
        font-size: 20px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        padding: 0 32px;
        box-sizing: border-box;
      }
    }
    .zhuce {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      width: 100%;
      height: 18px;
      font-size: 18px;
      padding: 0 26px;
      font-family: Source Han Sans CN;
      font-weight: bold;
      color: #ff6305;
      & > span:nth-child(2) {
        color: #999999;
        cursor: pointer;
      }
      & > span:nth-child(1) {
        cursor: pointer;
      }
    }
    .login {
      width: 100%;
      height: 64px;
      border-radius: 32px;
      // background: linear-gradient(-47deg, #70dac4, #3ec4a7);
      background: linear-gradient(135deg, #4c9bdd, #63b5fa);
      box-shadow: 2px 8px 9px 0px rgba(138, 138, 138, 0.12);
      text-align: center;
      font-size: 23px;
      font-family: Source Han Sans CN;
      font-weight: bold;
      color: #ffffff;
      line-height: 64px;
      margin-top: 55px;
      letter-spacing: 10px;
      cursor: pointer;
    }
    // 其他平台登录
    .other_login {
      display: flex;
      align-items: center;
      box-sizing: border-box;
      padding-left: 56px;
      padding-right: 64px;
      margin-top: 36px;
      margin-bottom: 34px;
      .line {
        width: 82px;
        height: 1px;
        border: 1px solid #bbbbbb;
      }
      .text {
        font-size: 18px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #999999;
        margin: 0 25px;
      }
    }
    .platform {
      display: flex;
      align-items: center;
      padding-left: 102px;
      padding-right: 82px;
      box-sizing: border-box;
      justify-content: space-between;
      & > div {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        img {
          width: 56px;
          height: 56px;
        }
        span {
          margin-top: 22px;
          font-size: 18px;
          font-family: Source Han Sans CN;
          font-weight: 400;
          color: #333333;
        }
      }
    }
  }
}
.login_hg_left {
  float: left;
  position: absolute;
  left: -180px;
  top: -390px;
}
.login_input {
  margin: 20px 0 20px 0;
}

.login_btn {
  margin-top: 20px;
  width: 100%;
  font-size: 14px;
}
.form-group {
  margin-bottom: 20px;
}
.must_rad {
  font-size: 12px;
}
.Dblock {
  display: block;
  font-size: 12px;
}
</style>

